#include "StdAfx.h"
#include "BtnSTToolBar.h"

BtnSTToolBar::BtnSTToolBar()
{
}

BtnSTToolBar::~BtnSTToolBar()
{
}

void BtnSTToolBar::DrawChangeToLight(CDC* pDC, CRect itemRect)
{
    CRect focusRect = itemRect;

    int black = 150;
    for (int i = 0; i < 1; i++)
    {
        focusRect.DeflateRect(1, 1);
        pDC->FillSolidRect(focusRect, RGB(black, black, black));
        black += 50;
    }

    for (int i = 0; i < 2; i++)
    {
        focusRect.DeflateRect(1, 1);
        pDC->FillSolidRect(focusRect, RGB(black, black, black));
        black += 20;

        if (black>255) black = 255;
    }

    for (int i = 0; i < 5; i++)
    {
        focusRect.DeflateRect(1, 1);
        pDC->FillSolidRect(focusRect, RGB(black, black, black));
        black += 5;

        if (black>255) black = 255;
    }
}

void BtnSTToolBar::DrawFocusBitmap(CDC* pDC, CRect itemRect)
{
    CRect focusRect = itemRect;
    //focusRect.DeflateRect(2, 2);
    pDC->Draw3dRect(focusRect, ::GetSysColor(COLOR_BTNSHADOW), ::GetSysColor(COLOR_BTNHILIGHT));

    DrawChangeToLight(pDC, focusRect);
}

void BtnSTToolBar::DrawMouseMoveBitmap(CDC* pDC, CRect itemRect)
{
    CRect focusRect = itemRect;
    //focusRect.DeflateRect(2, 2);
    pDC->Draw3dRect(focusRect, ::GetSysColor(COLOR_BTNSHADOW), ::GetSysColor(COLOR_BTNHILIGHT));

    pDC->FillSolidRect(focusRect, RGB(202, 202, 202));

    focusRect.DeflateRect(1, 1);
    pDC->FillSolidRect(focusRect, RGB(242, 242, 242));
}

void BtnSTToolBar::OnButtonClicked()
{
    int id = this->GetDlgCtrlID();

    CString csText;
    this->GetWindowText(csText);
    //this->m_ToolTip.GetText(csText, this, 1);
    GetParent()->SendMessage(WM_USER + 125, 0, (LPARAM)(const char*)id);

    if (m_bSetFocusByUser) m_bIsFocused = TRUE;
}
